package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleConfigService;
import com.heima.article.service.ApArticleService;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmFindNewsCommentsDto;
import com.heima.model.wemedia.dtos.WmNewsPageDto;
import com.heima.model.wemedia.dtos.WmUpdateCommentStatusDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


@RestController
public class ApArticleController {
    @Autowired
    private ApArticleService apArticleService;
    @Autowired
    private ApArticleConfigService apArticleConfigService;

    //分页查询 图文统计
    @PostMapping("/api/v1/article/newPage")
    public PageResponseResult newPage(@RequestBody WmNewsPageDto dto) {
        return apArticleService.newPage(dto);
    }

    //图文数据统计
    @GetMapping("/api/v1/article/newsDimension")
    public ResponseResult newsDimension(@RequestParam("beginDate") Date beginDate, @RequestParam("endDate") Date endDate) {
        return apArticleService.newsDimension(beginDate, endDate);
    }

    //查看评论列表
    @PostMapping("/api/v1/article/findNewsComments")
    public PageResponseResult findNewsComments(@RequestBody WmFindNewsCommentsDto dto) {
        return apArticleService.findNewsComments(dto);
    }

    //打开和关闭评论
    @PostMapping("/api/v1/article/updateCommentStatus")
    public ResponseResult updateStatus(@RequestBody WmUpdateCommentStatusDto dto) {
        return apArticleConfigService.updateCommentStatus(dto);
    }

}
